import type { AddressInfo, AddressParams } from '@/types/address'
import { http } from '@/utils/http'

//地址管理业务接口
export const addAddressAPI = (data: AddressParams) => {
  return http<number>({
    method: 'POST',
    url: '/member/address',
    data,
  })
}

//删除收货地址接口
export const deleteAddressAPI = (id: string) => {
  return http<number>({
    method: 'DELETE',
    url: `/member/address/${id}`,
  })
}

//修改收货地址接口
export const updateAddressAPI = (data: AddressParams, id: string) => {
  return http<number>({
    method: 'PUT',
    url: `/member/address/${id}`,
    data,
  })
}

//获取收货地址详情
export const getAddressDetailAPI = (id: string) => {
  return http<AddressInfo>({
    method: 'GET',
    url: `/member/address/${id}`,
  })
}

//获取收货地址列表
export const getAddressListAPI = () => {
  return http<AddressInfo[]>({
    method: 'GET',
    url: '/member/address',
  })
}
